<?php 
/**
* @package		MijoPolls
* @copyright	2009-2012 Mijosoft LLC, www.mijosoft.com
* @license		GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/

// no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<div  class="container enqueteresultado">
<h3>Resultado da Enquete</h3>


<div class="c">

<br /><br />
<?php echo $this->escape($this->params->get('page_title')); ?>

<br /><br />


<?php if (!$this->allowToVote) { 
	    if ($this->params->get('show_component_msg')) { 
	    	echo "<p>".JText::_($this->msg)."</p>"; 
	    }
	} ?>


<br /><br />

<b><?php echo JText::_('COM_MIJOPOLLS_STATISTICS'); ?>:</b>
<br />
<br />
<?php     
    // set the correct view
    if ($this->params->get('show_what', '0') == '1') {
        echo $this->loadTemplate('pie');
    } else {
        echo $this->loadTemplate('chart');
    }
?>
<br />

<?php if ($this->params->get('show_voters') || $this->params->get('show_times')) { ?>
<table cellspacing="0" cellpadding="0" border="0">
	<tbody>
		
		<tr>
			<td class="smalldark">
				<?php echo JText::_('COM_MIJOPOLLS_NUM_OF_VOTERS'); ?>
			</td>
			<td class="smalldark">
				&nbsp;
				<?php 
					if (isset($this->options[0])) {
						echo $this->options[0]->voters;
					}
				?>
		   </td>
		</tr>
		
		
		<?php if ($this->params->get('show_times')) { ?>
		<tr>
			<td class="smalldark">
				<?php echo JText::_('COM_MIJOPOLLS_START'); ?>
			</td>
			<td class="smalldark">
				&nbsp;
				<?php echo $this->poll->publish_up; ?>
			</td>
		</tr>
		<tr>
			<td class="smalldark">
				<?php echo JText::_('COM_MIJOPOLLS_END'); ?>
			</td>
			<td class="smalldark">
				&nbsp;
				<?php echo $this->poll->publish_down; ?>
			</td>
		</tr>
		<?php } ?>
	</tbody>
</table>
<?php }


$comments = $this->params->get('show_comments', '0');

if ($comments != 0) {
	$jcomments = JPATH_SITE . '/components/com_jcomments/jcomments.php';
	$jomcomment = JPATH_SITE . '/plugins/content/jom_comment_bot.php';
	$jxcomments = JPATH_SITE . '/components/com_comments/comments.php';
	$jacomments1 = JPATH_SITE . '/components/com_jacomment/jacomment.php';
	$jacomments2 = JPATH_SITE . '/plugins/system/jacomment.php';
	
	if ($comments == 1 && file_exists($jcomments)) {
		require_once($jcomments);
		echo JComments::showComments($this->poll->id, 'com_mijopolls', $this->poll->title);
	}
	
	if ($comments == 2 && file_exists($jomcomment)) {
		require_once($jomcomment);
		echo jomcomment($this->poll->id, "com_mijopolls");
	}
	
	if ($comments == 3 && file_exists($jxcomments)) {
		$url = 'index.php?option=com_mijopolls&view=poll&id='.(int) $this->poll->id;
		$route = $url.':'.$this->poll->alias.'&Itemid='.JRequest::getInt('Itemid');
		
		JHTML::addIncludePath(JPATH_SITE.'/components/com_comments/helpers/html');
		JHTML::_('comments.comments', 'mijopolls', $this->poll->id, $url, $route, $this->poll->title);
	}
	
	if ($comments == 4 && file_exists($jacomments1) && file_exists($jacomments2) && !JRequest::getInt('print')) {
		$_jacCode = "#{jacomment(.*?) contentid=(.*?) option=(.*?) contenttitle=(.*?)}#i";
		$_jacCodeDisableid = "#{jacomment(\s)off.*}#i";
		$_jacCodeDisable = "#{jacomment(\s)off}#i";
		if (!preg_match($_jacCode, $this->poll->title) && !preg_match($_jacCodeDisable, $this->poll->title) && !preg_match($_jacCodeDisableid, $this->poll->title)) {
			echo '{jacomment contentid='.$this->poll->id.' option=com_mijopolls contenttitle='.$this->poll->title.'}';
		}
	}
}
?>

<br style="clear:both" />
</div>
</div>